package com.ryskoo.catering.dinnertable.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.dinnertable.domain.DinnerTablePO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Primary
@Repository
public class DinnerTableRedisImpl extends BasicRedisImpl<DinnerTablePO> implements IDinnerTableRepository {

    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private IDinnerTableRepository dinnerTableRepository;

    @PostConstruct
    public void init() {
        this.setRedisClient(redisClient);
        this.setDao(dinnerTableRepository);
    }

    public DinnerTableRedisImpl(){super(HCLCacheConstant.HCL_DINNERTABLE_KEY);}

    @Override
    public List<String> getUuidsByTypeUuid(String typeUuid) {
        return dinnerTableRepository.getUuidsByTypeUuid(typeUuid);
    }

    @Override
    public List<String> getUuidByNoAndVendorId(String no, String vendorId) {
        return dinnerTableRepository.getUuidByNoAndVendorId(no,vendorId);
    }

    @Override
    public List<String> getUuidByNoAndVendorIdForUpdate(String no, String vendorId, String uuid) {
        return dinnerTableRepository.getUuidByNoAndVendorIdForUpdate(no,vendorId,uuid);
    }

	@Override
	public void updateState(String uuid, String state) {
		dinnerTableRepository.updateState(uuid,state);
	}
}
